#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QTextCodec>
#include <QFile>
#include <QTextStream>
#include <QString>
int main(int argc, char *argv[])
{
    QString OS,str,str2;
    int i;

    str = argv[0];
    for(i = 0; i < 4; i++)
    {
        str2[i] = str[str.length()-1-i];
    }
    if(str2 == "exe.")
    {
        OS = "Windows";
        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1251"));
    }
    else
    {
        OS = "Linux";
        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    }
    if(argc == 1)
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.setOS(OS);
        w.show();
        return a.exec();
    }
    if(argc == 3)
    {        
        QApplication a(argc, argv);
        MainWindow w;
        w.setOS(OS);
        QFile input_world_file(argv[1]);
        input_world_file.open(QIODevice::ReadOnly);
        QTextStream in(&input_world_file);
        in.setCodec("Windows-1251");
        w.Create_World_Function(in.readAll());
        input_world_file.close();
        w.return_Prog_World().Drawing_World(argv[2]);
        a.exit();
        return 0;
    }
}
